import math

import pandas as pd

# excel生成oracle字典表插入语句
if __name__ == '__main__':
    file_path = 'C:/Users/asyf/Desktop/dict.xlsx'
    # 使用read_excel函数读取Excel文件并将其存储为DataFrame对象
    df = pd.read_excel(file_path, converters={'gd_code': str, 'condition_01': str})
    for index, row in df.iterrows():
        gd_type = row['gd_type']
        gd_code = row['gd_code']
        desc_loc = row['desc_loc']
        condition_01 = row['condition_01']
        condition_02 = row['condition_02']
        # if condition_01 is None or math.isnan(condition_01):
        #     condition_01 = ''
        # if condition_02 is None or math.isnan(condition_02):
        #     condition_02 = ''
        sql = "insert into zcn_gd2_fr_mas_type (GD_TYPE, GD_CODE, DESC_LOC, CONDITION_01,CONDITION_02, USER_CREATE, CREATE_DATE,id)" + \
              " values ('{}', '{}', '{}','{}','{}', 'yjz', sysdate,seq_primary_key.nextval);".format(gd_type, gd_code, desc_loc, condition_01,
                                                                             condition_02)
        sql = sql.replace("'nan'", "''")
        print(sql)
